#ifndef FUZZYCONTROLLER_H
#define FUZZYCONTROLLER_H

#include <QVector3D>

#include "systemcontrol.h"
#include "collection.h"
#include "trianglemf.h"
#include "trapezoidmf.h"

class FuzzyController
{
public:
    FuzzyController(SystemControl* system = 0);

    /** Fuctions for converting between sets will be located here unless an
     * easier way is found.  All the logic should be transferable though
     */
    GraphicalMF* getTriangleMF(GraphicalMF* from) const;
    GraphicalMF* getTrapezoidMF(GraphicalMF* from) const;

    /** Get the crisp output from two input values */
    double getCrispOutput(const double &inputA, const double &inputB) const;

    /** Functions that are needed for the general flow of the Fuzzy Control */
    QVector3D** get3Doutput() const;

    /** Static functions for basic fuzzy logic concepts: */
    static inline double conjunction(const double &a, const double &b)
    { return a < b ? a : b; }
    static inline double disjunction(const double &a, const double &b)
    { return a > b ? a : b; }
    static inline double negation(const double &a) { return 1 - a; }

    bool containsSet(const QVector<BasicMembershipFunction *>& list,
                     const QString& name) const;

    void makeOctaveFile(QVector3D** data, const int& iterations) const;

private:

    SystemControl* m_system;
};

#endif // FUZZYCONTROLLER_H
